package com.googlecode.mgwt.examples.uibinder.client.activities.examples;

import java.util.LinkedList;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Widget;
import com.googlecode.mgwt.examples.uibinder.client.BasicCell;
import com.googlecode.mgwt.examples.uibinder.client.Topic;
import com.googlecode.mgwt.ui.client.widget.CellList;

public class ExampleDisplayCellListGwtImpl extends AbstractExampleDisplayGwtImpl {

	private static ExampleDisplayCellListGwtImplUiBinder uiBinder = GWT.create(ExampleDisplayCellListGwtImplUiBinder.class);

	interface ExampleDisplayCellListGwtImplUiBinder extends UiBinder<Widget, ExampleDisplayCellListGwtImpl> {
	}

	@UiField(provided = true)
	CellList<Topic> cellList;

	public ExampleDisplayCellListGwtImpl() {
		cellList = new CellList<Topic>(new BasicCell<Topic>() {

			@Override
			public String getDisplayString(Topic model) {
				return model.getName();
			}
		});
		initWidget(uiBinder.createAndBindUi(this));

		List<Topic> models = new LinkedList<Topic>();

		for (int i = 0; i < 20; i++) {
			models.add(new Topic("Source " + (i + 1)));
		}

		cellList.render(models);
	}

}
